home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / usr / sbin / update-usbids < prev    next >
Encoding:
Text File  |  2007-03-08  |  672 b   |  39 lines

  1. #!/bin/sh
  2.  
  3. # see also update-pciids.sh (fancier)
  4.  
  5. set -e
  6.  
  7. SRC="http://linux-usb.sourceforge.net/usb.ids"
  8. DEST=/var/lib/misc/usb.ids
  9.  
  10. umask 022
  11.  
  12. if which wget >/dev/null ; then
  13.     DL="wget -O $DEST.new $SRC"
  14. elif which lynx >/dev/null ; then
  15.     DL="eval lynx -source $SRC >$DEST.new"
  16. else
  17.     echo >&2 "update-usbids: cannot find wget nor lynx"
  18.     exit 1
  19. fi
  20.  
  21. if ! $DL ; then
  22.     echo >&2 "update-usbids: download failed"
  23.     rm -f $DEST.new
  24.     exit 1
  25. fi
  26.  
  27. if ! grep >/dev/null "^C " $DEST.new ; then
  28.     echo >&2 "update-usbids: missing class info, probably truncated file"
  29.     exit 1
  30. fi
  31.  
  32. if [ -f $DEST ] ; then
  33.     mv $DEST $DEST.old
  34. fi
  35. gzip -9 -c -n $DEST.new > $DEST
  36. rm -f $DEST.new
  37.  
  38. echo "Done."
  39.